package jeons.lately.action;

import jeons.lately.biz.LatelyBiz;
import jeons.lately.dto.LatelyDTO;

import org.springbyexample.web.servlet.view.tiles2.TilesUrlBasedViewResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("lately")
public class LatelyAction {
	@Autowired TilesUrlBasedViewResolver tilesUrlBasedViewResolver;
	@Autowired LatelyBiz latelyBiz;
	
	
	/**
	* @Method Name  : insertData
	* @작성일   : 2012. 2. 24.
	* @작성자   : user
	* @변경이력  :
	* @Method 설명 : 등록
	* @param url
	* @param img
	* @param sessionid
	*/
	@RequestMapping(value="/insert", method=RequestMethod.GET)
	public @ResponseBody void insertData(@RequestParam("url")String url, @RequestParam("img")String img, @RequestParam("sessionid")String sessionid){
//		tilesUrlBasedViewResolver.setTilesDefinitionName("tmpl");
		LatelyDTO latelyDTO = new LatelyDTO(url, sessionid, img);
		latelyBiz.insertData(latelyDTO);
	}
	
	/**
	* @Method Name  : getList
	* @작성일   : 2012. 2. 24.
	* @작성자   : user
	* @변경이력  :
	* @Method 설명 : 리스트 
	* @param model
	* @param sessionid
	* @return
	*/
	@RequestMapping(value="/list", method=RequestMethod.GET)
	public String getList(Model model,@RequestParam("sessionid")String sessionid){
		tilesUrlBasedViewResolver.setTilesDefinitionName("tmpl");
		model.addAttribute("latelylist",latelyBiz.getList(sessionid));
		return "lately/index";
	}
}
